package org.aceor.tennis.web;

import org.aceor.tennis.common.domain.User;
import retrofit2.http.*;
import rx.Observable;

import java.util.List;

/**
 * Created by lxue on 16/5/13.
 */
public interface IUserService {
    String ENDPOINT = "http://127.0.0.1:8080/user/";

    /**
     * 增
     * @param user
     * @return
     */
    @POST("users")
    Observable<BaseResult<String>> addUser(@Body User user);

    /**
     * 增
     * @param userId
     * @return
     */
    @DELETE("{userId}")
    Observable<BaseResult<String>> delUser(@Path("userId") Long userId);

    /**
     * 改
     * @param userId
     * @param user
     * @return
     */
    @PUT("{userId}")
    Observable<BaseResult<String>> updateUser(@Path("userId") Long userId,
                                              @Body User user);

    /**
     * 查单个
     * @param userId
     * @return
     */
    @GET("{userId}")
    Observable<BaseResult<User>> findUser(@Path("userId") Long userId);

    /**
     * 查列表
     * @return
     */
    @GET("users")
    Observable<BaseResult<List<User>>> findUserList();

    @POST("login")
    @FormUrlEncoded
    Observable<BaseResult<User>> login(@Field("id") Long id, @Field("nickName") String nickName);
}
